package com.bajiao.service.agreement.impl;

import com.bajiao.entity.agreement.Agreement;
import com.bajiao.mapper.agreement.AgreementMapper;
import com.bajiao.service.agreement.AgreementService;
import org.springframework.stereotype.Service;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

/**
 * @Description: 协议表
 * @Author: FanJq
 * @Date:   2024-12-23
 * @Version: V1.0
 */
@Service
public class AgreementServiceImpl extends ServiceImpl<AgreementMapper, Agreement> implements AgreementService {

    /**
     * @Description
     * 根据code获取
     * @date 2024/12/23 18:10
     * @author FanJq
     * @param code
     * @return {@link Agreement}
    */
    @Override
    public Agreement getByCode(String code) {
        Agreement agreement = super.lambdaQuery().eq(Agreement::getCode, code).one();
        super.lambdaUpdate().setSql("browse = browse + 1").eq(Agreement::getId, agreement.getId()).update();
        return agreement;
    }
}
